package sctu.edu.java.year2016.team07.shihaocheng.day20160521.Chapter5_3;

/**
 * Created by admin on 2016/5/22.
 *创建一个arr[][]二维数组,并输出所有元素的和
 */
import java.util.Scanner;
public class chapter5_3 {
    public static void main(String[] args) {
        Scanner in=new Scanner(System.in);
        int n,i,m,j;
        int sum = 0;
        System.out.print("请输入数组a[]的行数:");

        n=in.nextInt();

        System.out.print("请输入数组a[]的列数:");

        m=in.nextInt();

        int[][] a=new int[n][m];

        System.out.println("请输入数组");

        for(i=0;i<n;i++){
            for (j=0;j<m;j++)
            {
                a[i][j]=in.nextInt();}

        }

        for(i=0;i<n;i++){
            for(j=0;j<m;j++){
            sum = sum + a[i][j];
            }
        }

        System.out.println(""+sum);
        }
}
